
import { useInventoryStore, useMainStore } from '@/store';


function popup() {
	return {
		/** 
		 * 当审批流数量大于1时，打开选项弹层
		 * @param {Object} params 
		 */
		show: (params : any) => {
			console.log(params);
			const inventoryStore = useInventoryStore();
			const mainStore = useMainStore();

			inventoryStore.st_comPageConfig.showGlobalPopup = true;
			mainStore.BaseScreenParm = params;

			uni.navigateTo({
				url: "/commonPage/m-node-warp/componentsPage/m-global-popup/m-global-popup",
				events: {
					confirm: function (data : any) {
						params.confirm && params.confirm()
					},
					cancel: function (data : any) {
						params.cancel && params.cancel()
					}
				}
			})

		},
		/**
		 * 审批单据弹层
		 * @param {Object} params
		 */
		showFormApprove(params : any) {
			const inventoryStore = useInventoryStore();
			const mainStore = useMainStore();

			inventoryStore.st_comPageConfig.showFormApprove = true;
			mainStore.BaseScreenParm = params;

			uni.navigateTo({
				url: '/commonPage/m-node-warp/componentsPage/m-global-popup/m-form-approve-popup',
				events: {
					confirm: function (data : any) {
						params.confirm && params.confirm(data)
					},
					doneConfirm: function (data : any) {
						params.doneConfirm && params.doneConfirm(data)
					},
					cancel: function (data : any) {
						params.cancel && params.cancel(data)
					}
				}
			})
		},
		/**
		 * 查看审批流记录
		 * @param {Object} params
		 */
		showListApprove(params : any) {
			const inventoryStore = useInventoryStore();
			const mainStore = useMainStore();
			inventoryStore.st_comPageConfig.showListApprove = true;
			mainStore.BaseScreenParm = params;
			uni.navigateTo({
				url: '/commonPage/m-node-warp/componentsPage/m-global-popup/m-approve-list-page',
				events: {
					confirm: function (data : any) {
						params.confirm && params.confirm(data)
					},
					cancel: function (data : any) {
						params.cancel && params.cancel(data)
					}
				}
			})

		}
	}
}
export default popup();